home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / fmtmac.tes < prev    next >
Text File  |  1991-07-11  |  4KB  |  173 lines

  1. !MACRO formatter!
  2. ! * * * * * * * * * * * * * * * * * * * !
  3. !                    !
  4. !          FMTMAC.TEC        !
  5. !     !!FMTMAC.TEC V39.00!!        !
  6. !                    !
  7. !     Last edit on  2-Jun-83 by MHB    !
  8. !                    !
  9. ! * * * * * * * * * * * * * * * * * * * !
  10. !                    !
  11. ! This is a PDP-11 macro (.MAC) source    !
  12. !  program formatter that runs under    !
  13. !  VTEDIT.TEC.                !
  14. !                    !
  15. ! The algorithm used is very simple and    !
  16. !  handles the necessary upper case    !
  17. !  conversions needed to obey the    !
  18. !  macro source program formatting    !
  19. !  standard:                !
  20. !                    !
  21. !    Everything is in upper case    !
  22. !    except for comments (everything    !
  23. !    after a semi-colon [;]) and    !
  24. !    everything following the assembler    !
  25. !    directives:            !
  26. !    1) .ASCII, .ASCIZ, etc.        !
  27. !       [found as .ASCIa]        !
  28. !    2) .TITLE            !
  29. !    3) .SBTTL            !
  30. !                    !
  31. ! The algorithm also automatically    !
  32. !  aligns comments on the 4th tab stop.    !
  33. !                    !
  34. ! * * * * * * * * * * * * * * * * * * * !
  35. !                    !
  36. ! Environment:                !
  37. !                    !
  38. ! This macro is invoked whenever a text    !
  39. !  buffer insert must be done.  The    !
  40. !  macro figures out the correct case    !
  41. !  for the insert, does the insert, and    !
  42. !  all further insert(s) until a non-    !
  43. !  insert character (i.e., a command    !
  44. !  character) is encountered.        !
  45. !                    !
  46. ! Entry values:                !
  47. !                    !
  48. !  7% Character to insert into text    !
  49. !                    !
  50. ! Exit values:                !
  51. !                    !
  52. !  7% Exception character (set by M3)    !
  53. !                    !
  54. ! Q-register usage:            !
  55. !                    !
  56. !  M$ This macro            !
  57. !  M% Exception character(s) for 8M3    !
  58. !  2$ Local scratch            !
  59. !  2% Local scratch (clobbered by M3)    !
  60. !  3% Local scratch (clobbered by M3)    !
  61. !  4$ Local scratch            !
  62. !  4% Local scratch (clobbered by M3)    !
  63. !  5% Local scratch (clobbered by M3)    !
  64. !  6% Local scratch (clobbered by M3)    !
  65. !  7% Exception character (set by M3)    !
  66. !                    !
  67. ! * * * * * * * * * * * * * * * * * * * !
  68. !                    !
  69. ! If character is not a semi-colon then    !
  70. !  Insert character into text buffer    !
  71. Q7-^^;"N
  72.   Q7@I%%
  73. '
  74. ! Save dot                !
  75. .U3
  76. ! Guess at lower case inserts (0)    !
  77. ! Guess at no exception characters (0)    !
  78. ! Check for being beyond a semi-colon    !
  79. ! (beyond ; => lc, no exceptions)    !
  80. ! If not beyond a semi-colon then    !
  81. !  Set upper case inserts (4)        !
  82. !  Set exception characters to ";", "."    !
  83. !  Check for being beyond a dot        !
  84. !  (not beyond . => uc until ; or .)    !
  85. !  If beyond a dot then            !
  86. !   Set upper case inserts (4)        !
  87. !   Set <TAB> as an exception (2)    !
  88. !   Set exception characters to ";",<SP>!
  89. !   Check for .aaaaa directive        !
  90. !   (no .aaaaa => uc until ; or blank)    !
  91. !   If .aaaaa directive then        !
  92. !    If we're after it then        !
  93. !     Back up to face the directive    !
  94. !     If it's .ASCIa, etc. then        !
  95. !      Set lower case inserts (0)    !
  96. !      Set no exception characters (0)    !
  97. 0U5
  98. 0UM
  99. 0:@FB%;%"U
  100.   4U5
  101.   ^^;*256+^^.UM
  102.   0:@FB%.%"S
  103.   4#2U5
  104.   ^^;*256+32UM
  105.     ::@S%^EA^EA^EA^EA^EA^ES%"S
  106.       Q3-.+1"G
  107.         ^SC
  108.         ::@S%ASCI%"U
  109.           ::@S%TITLE%"S F| '
  110.           ::@S%SBTTL%"S F| '
  111.         |
  112.           0U5
  113.           0UM
  114.         '
  115.       '
  116.     '
  117.   '
  118. '
  119. ! Restore dot                !
  120. Q3J
  121. ! Correct case of insert if needed    !
  122. Q7"V
  123.   Q5"N
  124.     -D Q7-32@I%%
  125.   '
  126. '
  127. ! If the character is semi-colon then    !
  128. !  Insert the semi-colon into buffer    !
  129. !  If we're in upper case mode then    !
  130. !   If we're not at line's start then    !
  131. !    If at end-of-buffer then        !
  132. !     Insert and back over a <CR><LF>    !
  133. !    If we're at line's end then    !
  134. !     Delete any trailing blanks    !
  135. !     Find position of the semi-colon    !
  136. !     Find distance to desired position    !
  137. !     If we need spacing then        !
  138. !      Insert correct number of <TAB>s    !
  139. !     Else                !
  140. !      Insert a single <SP>        !
  141. !     Skip semi-colon and insert a <SP>    !
  142. !  Set lower case inserts (0)        !
  143. !  Set no exception characters (0)    !
  144. Q7-^^;"E
  145.   @I%;%
  146.   Q5"N
  147.     0^Q+1"N
  148.       .-Z"E
  149.         13@I%% 10@I%% 2R
  150.       '
  151.       ::@S%^M^J%"S
  152.         3R < 0^Q; R ::@FS%^ES%%; >
  153.         0L 0U3 ^Q-3< %3^[ 0A-9"E -Q3&7%3^[ ' C >
  154.         32-Q3U3
  155.         Q3"G
  156.           Q3+7/8< 9@I%% >
  157.         |
  158.           32@I%%
  159.         '
  160.         C 32@I%%
  161.       '
  162.     '
  163.   '
  164.   0U5
  165.   0UM
  166. '
  167. ! Read from terminal doing insert(s)    !
  168. !  with correct case (Q5)        !
  169. !  using exception characters (8)    !
  170. Q5#8M3^[
  171. !                    !
  172. ! * * * * * * * * * * * * * * * * * * * !